/**
 * 
 */
package cc.comac.mom.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.EquipCheckDetailService;
import cc.comac.mom.bean.EquipCheckDetail;
import cc.comac.mom.bean.EquipCheckDetailBean;
import cc.comac.mom.bean.ResultDev;
import cc.comac.mom.datahandlers.entity.EquipCheckDetailDataHandler;
import cc.comac.mom.datahandlers.entity.EquipDevDataHandler;
import cc.comac.mom.util.ResultBean;

/**
* @Description: 
* @author: fyt 
* @date: 2020年7月21日下午4:23:23
*/
@RestController
@Service
public class EquipCheckDetailServiceImpl implements EquipCheckDetailService {

	@Autowired
	private EquipCheckDetailDataHandler equipCheckDetailDataHandler;	
	@Autowired
	private EquipDevDataHandler equipDevDataHandler;
	@Override
	public ResultBean selectEquipCheckDetailByCheckId(@RequestBody EquipCheckDetailBean obj) {
		ResultBean resultBean = new ResultBean(true);
		ResultDev resultDev = equipCheckDetailDataHandler.selectEquipCheckDetailByCheckId(obj);
		resultBean.setObject(resultDev);
		return resultBean;
	}
	@Override
	public ResultBean deleteBatch(@RequestBody List<EquipCheckDetail> list) {

		return equipCheckDetailDataHandler.deleteBatch(list);
	}
	@Override
	public ResultBean equipCheckDetailChecked(@RequestBody List<EquipCheckDetail> list) {
		ResultBean resultBean = new ResultBean(true);
		ResultBean resultBean2 = equipCheckDetailDataHandler.equipCheckDetailChecked(list);
		if(!resultBean2.success) {
			return resultBean2;
		}
		ArrayList<Long> listDevId = new ArrayList<Long>();
		for(EquipCheckDetail item :list) {
			listDevId.add(item.getInnerData().getDevId());
		}
		ResultBean resultBean3 = equipDevDataHandler.updateInventoryDate(listDevId);
		if(!resultBean3.success) {
			throw new RuntimeException(resultBean3.getMessage());
		}
		return resultBean;
	}

}
